```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ArrayList vs LinkedList 深度解析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6B73FF 0%, #000DFF 50%, #0085FF 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            padding: 1.5rem;
            position: relative;
            overflow: hidden;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight {
            position: relative;
        }
        .highlight:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 30%;
            background-color: rgba(107, 114, 255, 0.2);
            z-index: -1;
            transition: height 0.3s ease;
        }
        .highlight:hover:after {
            height: 50%;
        }
        .mermaid {
            background-color: white;
            padding: 1.5rem;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .performance-chart {
            height: 300px;
            background: linear-gradient(to right, #6B73FF, #0085FF);
            border-radius: 0.5rem;
            position: relative;
            overflow: hidden;
        }
        .chart-bar {
            position: absolute;
            bottom: 0;
            width: 40%;
            background-color: white;
            transition: height 0.8s ease, opacity 0.3s ease;
            opacity: 0.9;
        }
        .chart-label {
            position: absolute;
            bottom: -30px;
            width: 100%;
            text-align: center;
            font-weight: 500;
            color: #333;
        }
        .footer-link:hover {
            color: #6B73FF !important;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4">ArrayList vs LinkedList</h1>
                    <p class="text-xl md:text-2xl mb-6 opacity-90">Java集合类的深度解析与性能对比</p>
                    <div class="flex items-center">
                        <span class="bg-white text-blue-600 px-4 py-2 rounded-full font-medium mr-3">Java集合框架</span>
                        <span class="bg-white text-blue-600 px-4 py-2 rounded-full font-medium">数据结构</span>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative w-full max-w-md">
                        <div class="absolute inset-0 bg-white opacity-10 rounded-xl transform rotate-6"></div>
                        <div class="relative bg-white bg-opacity-10 backdrop-filter backdrop-blur-sm p-6 rounded-xl border border-white border-opacity-20">
                            <div class="text-center">
                                <i class="fas fa-project-diagram text-5xl mb-4"></i>
                                <h3 class="text-2xl font-bold mb-2">数据结构可视化</h3>
                                <p class="opacity-90">探索两种列表的不同实现原理</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-5xl py-16 px-4">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold mb-4">理解核心差异</h2>
                <p class="text-lg text-gray-600 max-w-3xl mx-auto">ArrayList 和 LinkedList 是 Java 中两种常用的 List 实现，它们在底层实现、性能特点和适用场景上有着显著区别。正确选择可以显著提升程序性能。</p>
            </div>
            
            <!-- Comparison Cards -->
            <div class="grid md:grid-cols-2 gap-8 mb-16">
                <div class="bg-white p-8 rounded-xl shadow-lg card-hover transition-all duration-300">
                    <div class="flex items-center mb-6">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-table text-blue-600 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">ArrayList</h3>
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>基于动态数组实现</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>随机访问速度快 (O(1))</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>内存占用较小</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-exclamation-circle text-yellow-500 mt-1 mr-2"></i>
                            <span>中间插入/删除效率低 (O(n))</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white p-8 rounded-xl shadow-lg card-hover transition-all duration-300">
                    <div class="flex items-center mb-6">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-link text-purple-600 text-xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">LinkedList</h3>
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>基于双向链表实现</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>头部/尾部插入删除快 (O(1))</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-green-500 mt-1 mr-2"></i>
                            <span>适合频繁修改操作</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-exclamation-circle text-yellow-500 mt-1 mr-2"></i>
                            <span>随机访问速度慢 (O(n))</span>
                        </li>
                    </ul>
                </div>
            </div>
            
            <!-- Performance Visualization -->
            <div class="mb-16">
                <h3 class="text-2xl font-bold mb-6 text-center">性能对比可视化</h3>
                <div class="performance-chart mb-4">
                    <div class="chart-bar left-1/4 h-3/5" style="transform: translateX(-50%);">
                        <div class="chart-label">ArrayList 访问</div>
                    </div>
                    <div class="chart-bar left-3/4 h-1/5" style="transform: translateX(-50%);">
                        <div class="chart-label">LinkedList 访问</div>
                    </div>
                </div>
                <div class="performance-chart">
                    <div class="chart-bar left-1/4 h-2/5" style="transform: translateX(-50%);">
                        <div class="chart-label">ArrayList 插入/删除</div>
                    </div>
                    <div class="chart-bar left-3/4 h-4/5" style="transform: translateX(-50%);">
                        <div class="chart-label">LinkedList 插入/删除</div>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Detailed Comparison -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">详细对比分析</h2>
            
            <div class="space-y-12">
                <!-- 1. 底层实现 -->
                <div>
                    <div class="flex items-center mb-6">
                        <div class="bg-blue-600 text-white w-10 h-10 rounded-full flex items-center justify-center mr-4">
                            <span class="font-bold">1</span>
                        </div>
                        <h3 class="text-2xl font-bold highlight">底层实现</h3>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-gray-50 p-6 rounded-lg">
                            <h4 class="font-bold text-lg mb-3 text-blue-600">ArrayList</h4>
                            <p class="mb-4">基于动态数组(<code>Object[]</code>)实现。使用数组存储元素，数组大小会随着元素增加而动态调整。</p>
                            <div class="bg-blue-50 p-4 rounded">
                                <p class="font-medium mb-2">✅ 优点:</p>
                                <ul class="list-disc pl-5 space-y-1">
                                    <li>快速随机访问元素 (O(1))</li>
                                    <li>内存占用较小</li>
                                </ul>
                            </div>
                            <div class="bg-red-50 p-4 rounded mt-3">
                                <p class="font-medium mb-2">❌ 缺点:</p>
                                <ul class="list-disc pl-5 space-y-1">
                                    <li>中间插入/删除元素需要移动数组元素 (O(n))</li>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="bg-gray-50 p-6 rounded-lg">
                            <h4 class="font-bold text-lg mb-3 text-purple-600">LinkedList</h4>
                            <p class="mb-4">基于双向链表实现。由一系列节点(<code>Node</code>)组成，每个节点包含数据和指向前后节点的引用。</p>
                            <div class="bg-purple-50 p-4 rounded">
                                <p class="font-medium mb-2">✅ 优点:</p>
                                <ul class="list-disc pl-5 space-y-1">
                                    <li>头部/尾部插入删除高效 (O(1))</li>
                                </ul>
                            </div>
                            <div class="bg-red-50 p-4 rounded mt-3">
                                <p class="font-medium mb-2">❌ 缺点:</p>
                                <ul class="list-disc pl-5 space-y-1">
                                    <li>随机访问元素慢 (O(n))</li>
                                    <li>内存消耗更大</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    
                    <div class="mt-8">
                        <div class="mermaid">
                            graph LR
                                A[ArrayList] --> B[动态数组]
                                B --> C[连续内存]
                                B --> D[自动扩容]
                                
                                E[LinkedList] --> F[双向链表]
                                F --> G[节点包含数据和指针]
                                F --> H[非连续内存]
                        </div>
                    </div>
                </div>
                
                <!-- 2. 性能比较 -->
                <div>
                    <div class="flex items-center mb-6">
                        <div class="bg-blue-600 text-white w-10 h-10 rounded-full flex items-center justify-center mr-4">
                            <span class="font-bold">2</span>
                        </div>
                        <h3 class="text-2xl font-bold highlight">性能比较</h3>
                    </div>
                    
                    <div class="overflow-x-auto">
                        <table class="min-w-full bg-white rounded-lg overflow-hidden">
                            <thead class="bg-gray-100">
                                <tr>
                                    <th class="py-3 px-4 text-left font-semibold">操作类型</th>
                                    <th class="py-3 px-4 text-left font-semibold">ArrayList</th>
                                    <th class="py-3 px-4 text-left font-semibold">LinkedList</th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-200">
                                <tr>
                                    <td class="py-3 px-4">随机访问</td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-green-100 text-green-800 rounded-full text-sm">
                                            <i class="fas fa-bolt mr-1"></i> O(1) - 极快
                                        </span>
                                    </td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-red-100 text-red-800 rounded-full text-sm">
                                            <i class="fas fa-turtle mr-1"></i> O(n) - 慢
                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4">头部插入/删除</td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-red-100 text-red-800 rounded-full text-sm">
                                            O(n) - 需要移动元素
                                        </span>
                                    </td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-green-100 text-green-800 rounded-full text-sm">
                                            <i class="fas fa-bolt mr-1"></i> O(1) - 极快
                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4">尾部插入/删除</td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-green-100 text-green-800 rounded-full text-sm">
                                            平摊O(1)
                                        </span>
                                    </td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-green-100 text-green-800 rounded-full text-sm">
                                            <i class="fas fa-bolt mr-1"></i> O(1) - 极快
                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4">中间插入/删除</td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-red-100 text-red-800 rounded-full text-sm">
                                            O(n) - 需要移动元素
                                        </span>
                                    </td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-orange-100 text-orange-800 rounded-full text-sm">
                                            O(n) - 需要遍历
                                        </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="py-3 px-4">内存占用</td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-sm">
                                            较小 (仅存储数据)
                                        </span>
                                    </td>
                                    <td class="py-3 px-4">
                                        <span class="inline-flex items-center px-2 py-1 bg-purple-100 text-purple-800 rounded-full text-sm">
                                            较大 (节点额外存储指针)
                                        </span>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                
                <!-- 3. 线程安全性 -->
                <div>
                    <div class="flex items-center mb-6">
                        <div class="bg-blue-600 text-white w-10 h-10 rounded-full flex items-center justify-center mr-4">
                            <span class="font-bold">3</span>
                        </div>
                        <h3 class="text-2xl font-bold highlight">线程安全性</h3>
                    </div>
                    
                    <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-exclamation-triangle text-yellow-400 mt-1"></i>
                            </div>
                            <div class="ml-3">
                                <p class="text-yellow-700 font-medium">重要提示</p>
                                <p class="text-yellow-700 mt-1">ArrayList 和 LinkedList 都不是线程安全的。如果在多线程环境中使用，需要手动同步，或者使用 <code class="bg-yellow-100 px-1 rounded">Collections.synchronizedList</code> 方法来获得线程安全的列表。</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-gray-50 p-6 rounded-lg">
                            <h4 class="font-bold text-lg mb-3">示例: 线程不安全的ArrayList</h4>
                            <div class="code-block text-gray-200 font-mono text-sm">
                                <div class="mb-4">// 多线程环境下可能抛出ConcurrentModificationException</div>
                                <div class="mb-2">List&lt;String&gt; list = new ArrayList&lt;&gt;();</div>
                                <div class="mb-2">list.add("A");</div>
                                <div class="mb-2">list.add("B");</div>
                                <div class="mb-4"></div>
                                <div class="mb-2">// 线程1:</div>
                                <div class="mb-2">for (String s : list) {</div>
                                <div class="ml-4 mb-2">System.out.println(s);</div>
                                <div class="mb-4">}</div>
                                <div class="mb-2">// 线程2:</div>
                                <div class="mb-2">list.remove("A");</div>
                            </div>
                        </div>
                        
                        <div class="bg-gray-50 p-6 rounded-lg">
                            <h4 class="font-bold text-lg mb-3">解决方案: 线程安全的List</h4>
                            <div class="code-block text-gray-200 font-mono text-sm">
                                <div class="mb-4">// 使用Collections.synchronizedList</div>
                                <div class="mb-2">List&lt;String&gt; list = Collections.synchronizedList(new ArrayList&lt;&gt;());</div>
                                <div class="mb-2">list.add("A");</div>
                                <div class="mb-2">list.add("B");</div>
                                <div class="mb-4"></div>
                                <div class="mb-2">// 线程安全地遍历</div>
                                <div class="mb-2">synchronized (list) {</div>
                                <div class="ml-4 mb-2">for (String s : list) {</div>
                                <div class="ml-8 mb-2">System.out.println(s);</div>
                                <div class="ml-4 mb-2">}</div>
                                <div class="mb-2">}</div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- 4. 适用场景 -->
                <div>
                    <div class="flex items-center mb-6">
                        <div class="bg-blue-600 text-white w-10 h-10 rounded-full flex items-center justify-center mr-4">
                            <span class="font-bold">4</span>
                        </div>
                        <h3 class="text-2xl font-bold highlight">适用场景</h3>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="bg-blue-50 p-6 rounded-lg border border-blue-100">
                            <div class="flex items-center mb-4">
                                <div class="bg-blue-600 text-white p-2 rounded-full mr-3">
                                    <i class="fas fa-table"></i>
                                </div>
                                <h4 class="font-bold text-lg">ArrayList 适用场景</h4>
                            </div>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-blue-600 mt-1 mr-2"></i>
                                    <span>频繁读取操作，尤其是随机访问元素</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-blue-600 mt-1 mr-2"></i>
                                    <span>数据量较大但修改操作较少</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-blue-600 mt-1 mr-2"></i>
                                    <span>需要节省内存空间</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-blue-600 mt-1 mr-2"></i>
                                    <span>作为缓存使用</span>
                                </li>
                            </ul>
                        </div>
                        
                        <div class="bg-purple-50 p-6 rounded-lg border border-purple-100">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-600 text-white p-2 rounded-full mr-3">
                                    <i class="fas fa-link"></i>
                                </div>
                                <h4 class="font-bold text-lg">LinkedList 适用场景</h4>
                            </div>
                            <ul class="space-y-3">
                                <li class="flex items-start">
                                    <i class="fas fa-check text-purple-600 mt-1 mr-2"></i>
                                    <span>频繁在头部/尾部插入或删除元素</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-purple-600 mt-1 mr-2"></i>
                                    <span>实现栈、队列或双端队列</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-purple-600 mt-1 mr-2"></i>
                                    <span>数据量不大但修改频繁</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check text-purple-600 mt-1 mr-2"></i>
                                    <span>需要频繁在中间插入/删除元素</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    
                    <div class="mt-6">
                        <div class="mermaid">
                            flowchart TD
                                A[需要频繁随机访问?] -->|是| B[ArrayList]
                                A -->|否| C[需要频繁插入/删除?]
                                C -->|是| D[LinkedList]
                                C -->|否| B
                        </div>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Code Examples -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 text-center">代码示例</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-600 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-code"></i>
                        </div>
                        <h3 class="text-xl font-bold">ArrayList 示例</h3>
                    </div>
                    <div class="code-block text-gray-200 font-mono text-sm">
                        <div class="text-gray-400 mb-2">// ArrayListDemo.java</div>
                        <div class="mb-2"><span class="text-purple-400">import</span> java.util.ArrayList;</div>
                        <div class="mb-2"><span class="text-purple-400">import</span> java.util.List;</div>
                        <div class="mb-4"></div>
                        <div class="mb-2"><span class="text-purple-400">public class</span> <span class="text-blue-400">ArrayListDemo</span> {</div>
                        <div class="ml-4 mb-2"><span class="text-purple-400">public static void</span> <span class="text-yellow-300">main</span>(String[] args) {</div>
                        <div class="ml-8 mb-2">List&lt;String&gt; list = <span class="text-purple-400">new</span> ArrayList&lt;&gt;();</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-green-400">"Alice"</span>);</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-green-400">"Bob"</span>);</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-green-400">"Charlie"</span>);</div>
                        <div class="ml-8 mb-4"></div>
                        <div class="ml-8 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(<span class="text-green-400">"ArrayList 元素："</span>);</div>
                        <div class="ml-8 mb-2"><span class="text-purple-400">for</span> (String name : list) {</div>
                        <div class="ml-12 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(name);</div>
                        <div class="ml-8 mb-2">}</div>
                        <div class="ml-8 mb-4"></div>
                        <div class="ml-8 mb-2">// 随机访问</div>
                        <div class="ml-8 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(<span class="text-green-400">"第二个元素："</span> + list.<span class="text-yellow-300">get</span>(<span class="text-amber-400">1</span>));</div>
                        <div class="ml-4 mb-2">}</div>
                        <div class="mb-2">}</div>
                    </div>
                </div>
                
                <div>
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-600 text-white p-2 rounded-full mr-3">
                            <i class="fas fa-code"></i>
                        </div>
                        <h3 class="text-xl font-bold">LinkedList 示例</h3>
                    </div>
                    <div class="code-block text-gray-200 font-mono text-sm">
                        <div class="text-gray-400 mb-2">// LinkedListDemo.java</div>
                        <div class="mb-2"><span class="text-purple-400">import</span> java.util.LinkedList;</div>
                        <div class="mb-2"><span class="text-purple-400">import</span> java.util.List;</div>
                        <div class="mb-4"></div>
                        <div class="mb-2"><span class="text-purple-400">public class</span> <span class="text-blue-400">LinkedListDemo</span> {</div>
                        <div class="ml-4 mb-2"><span class="text-purple-400">public static void</span> <span class="text-yellow-300">main</span>(String[] args) {</div>
                        <div class="ml-8 mb-2">List&lt;String&gt; list = <span class="text-purple-400">new</span> LinkedList&lt;&gt;();</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-green-400">"Alice"</span>);</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-green-400">"Bob"</span>);</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-green-400">"Charlie"</span>);</div>
                        <div class="ml-8 mb-4"></div>
                        <div class="ml-8 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(<span class="text-green-400">"LinkedList 元素："</span>);</div>
                        <div class="ml-8 mb-2"><span class="text-purple-400">for</span> (String name : list) {</div>
                        <div class="ml-12 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(name);</div>
                        <div class="ml-8 mb-2">}</div>
                        <div class="ml-8 mb-4"></div>
                        <div class="ml-8 mb-2">// 插入操作</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">add</span>(<span class="text-amber-400">1</span>, <span class="text-green-400">"David"</span>);</div>
                        <div class="ml-8 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(<span class="text-green-400">"插入新元素后的列表："</span>);</div>
                        <div class="ml-8 mb-2"><span class="text-purple-400">for</span> (String name : list) {</div>
                        <div class="ml-12 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(name);</div>
                        <div class="ml-8 mb-2">}</div>
                        <div class="ml-8 mb-4"></div>
                        <div class="ml-8 mb-2">// 删除操作</div>
                        <div class="ml-8 mb-2">list.<span class="text-yellow-300">remove</span>(<span class="text-green-400">"Charlie"</span>);</div>
                        <div class="ml-8 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(<span class="text-green-400">"删除元素后的列表："</span>);</div>
                        <div class="ml-8 mb-2"><span class="text-purple-400">for</span> (String name : list) {</div>
                        <div class="ml-12 mb-2">System.<span class="text-blue-400">out</span>.<span class="text-yellow-300">println</span>(name);</div>
                        <div class="ml-8 mb-2">}</div>
                        <div class="ml-4 mb-2">}</div>
                        <div class="mb-2">}</div>
                    </div>
                </div>
            </div>
        </section>
        
        <!-- Summary -->
        <section class="mb-16 bg-blue-50 rounded-xl p-8">
            <h2 class="text-3xl font-bold mb-6 text-center">总结</h2>
            
            <div class="max-w-3xl mx-auto">
                <div class="mb-6">
                    <div class="flex items-center bg-white p-4 rounded-lg shadow-sm mb-3">
                        <div class="bg-blue-100 p-2 rounded-full mr-4">
                            <i class="fas fa-lightbulb text-blue-600"></i>
                        </div>
                        <div>
                            <h4 class="font-bold mb-1">选择ArrayList的情况</h4>
                            <p class="text-gray-600">当需要频繁随机访问元素，且插入和删除操作主要发生在列表末尾时，ArrayList是更好的选择。</p>
                        </div>
                    </div>
                    
                    <div class="flex items-center bg-white p-4 rounded-lg shadow-sm">
                        <div class="bg-purple-100 p-2 rounded-full mr-4">
                            <i class="fas fa-lightbulb text-purple-600"></i>
                        </div>
                        <div>
                            <h4 class="font-bold mb-1">选择LinkedList的情况</h4>
                            <p class="text-gray-600">当需要频繁在列表头部或中间插入/删除元素，或者需要实现队列、双端队列等数据结构时，LinkedList更合适。</p>
                        </div>
                    </div>
                </div>
                
                <div class="mermaid">
                    pie
                        title 使用场景分布
                        "ArrayList: 随机访问" : 70
                        "LinkedList: 频繁修改" : 30
                </div>
            </div>
        </section>
    </div>
    
    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-8 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center">
                <div class="mb-4">
                    <a href="http://www.yuque.com/jtostring" class="footer-link text-gray-300 hover:text-white transition duration-200">技术小馆</a>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="footer-link text-gray-400 hover:text-white transition duration-200">http://www.yuque.com/jtostring</a>
                </div>
            </div>
        </div>
    </footer>
    
    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
        
        // Animate performance charts
        document.addEventListener('DOMContentLoaded', function() {
            const chartBars = document.querySelectorAll('.chart-bar');
            
            // Only animate when the bars come into view
            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.style.opacity = '1';
                        observer.unobserve(entry.target);
                    }
                });
            }, {threshold: 0.1});
            
            chartBars.forEach(bar => {
                bar.style.opacity = '0';
                observer.observe(bar);
            });
        });
    </script>
</body>
</html>
```